"""
@author: mark
@contact: QQ:11241642375
@Created on: 2024年8月17日18:07:04
@Remark: 序列化器
"""
from yaml import serialize

from challenges.models import ChallengeItem, DeptChallenge
from dvadmin.utils.serializers import CustomModelSerializer
from rest_framework import serializers


class ChallengeItemSerializer(CustomModelSerializer):
    """
    序列化器
    """
    class Meta:
        model = ChallengeItem
        fields = "__all__"


class ChallengeItemCreateUpdateSerializer(CustomModelSerializer):
    """
    创建/更新时的列化器
    """

    class Meta:
        model = ChallengeItem
        fields = '__all__'


class DeptChallengeSerializer(CustomModelSerializer):
    """
    普通序列化起
    """
    # 获取外键序列化的名字
    department_name = serializers.CharField(source="department.name", read_only=True)

    class Meta:
        model = DeptChallenge
        fields = "__all__"


class DeptChallengeCreateUpdateSerializer(CustomModelSerializer):
    """
    普通序列化起
    """

    class Meta:
        model = DeptChallenge
        fields = "__all__"